<template >
    <button @click="onAdd">点击{{ num }}</button>
</template>
<script setup>
import {defineProps} from 'vue'

const props = defineProps({
    //接收父组件传过来的值
    num:Number
});
const emits = defineEmits(['add'])

// const{num} = props

// console.log(num);


function onAdd() {
    emits('add',props.num+1);
}

</script>


<!-- ChildComponent.vue -->
<!-- <template>
    <button @click="updateParentNum">{{ buttonText }} </button>
  </template>
  
  <script setup>
  import { defineProps, defineEmits } from 'vue'
  
  const props = defineProps({
    num: Number
  })
  
  const emits = defineEmits(['update-num'])
    
  function updateParentNum() {
    emits('update-num', props.num + 1)
  }

  const buttonText = `Increment Parent Num to ${props.num + 1}`
  </script> -->